﻿
@{
    ViewBag.Title = "短信发送黑名单日期";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content-header">
    <h1>
        @ViewBag.TaskName
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li><a href="#" id="preBtn">短信任务列表</a></li>
        <li class="active">短信发送黑名单日期</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <div class="bs-example">
                        <ul class="nav nav-tabs">
                            <li role="presentation"><a href="#" id="TaskTimes">短信任务执行周期</a></li>
                            <li role="presentation" class="active"><a href="#">黑名单日期</a></li>
                        </ul>
                    </div>
                    <div class="form-inline" style="margin-top:10px;">
                        <div class="form-group">
                            <button class="btn btn-primary" id="btnAdd" type="button">添加</button>
                        </div>

                        <h3 class="box-title"></h3>
                    </div>
                </div>

                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover body-table-head">
                        <colgroup>
                            <col style="width:15%" />
                            <col style="width:10%" />
                            <col style="width:10%" />
                        </colgroup>
                        <thead>
                            <tr>
                                <th>日期类型</th>
                                <th>日期值</th>
                                <th class="t_c">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tbodylist"></tbody>
                    </table>
                    <div class="no-data" id="nodata" style="display:none;">
                        <div class="img-box"></div>
                        <div class="text">暂无数据</div>
                    </div>
                </div>
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each rows}}
        <tr>
            <td>{{$value.DateTypeTxt}}</td>
            <td>{{$value.DataValueTxt}}</td>
            <td class="t_c">
                <button type="button" class="btn btn-info btn-xs" onclick="edit('{{$value.DayID}}')">修改</button>
                <button type="button" class="btn btn-danger btn-xs" onclick="del('{{$value.DayID}}')">删除</button>
            </td>
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            search();
            $("#preBtn").click(function () {
                var url = '@Url.Action("TaskList", "Sms")';
                location.href = url;
            });
            $("#btnAdd").click(function(){
                var taskid = @ViewBag.TaskId;
                var tl = '短信发送黑名单日期';
                var url = '@Url.Action("BlackDayEdit", "Sms")?taskid='+taskid;
                BMCW.showTopLayer(tl, url, 630, 298);
            });

            $("#TaskTimes").click(function(){
                var taskid = @ViewBag.TaskId;
                var url = '@Url.Action("TaskTimeList", "Sms")?id='+taskid;
                location.href = url;
            });
        });

        //页码
        var pageIndex = 1;
        //查询
        function search() {
            var url = '@Url.Action("BlackDaySearchList", "Sms")';
            var taskId = @ViewBag.TaskId;
            //查询列表
            $.ajax({
                url: url,
                type: 'GET',
                dataType: "json",
                data: {
                    rows: 10,
                    page: pageIndex,
                    taskid:taskId
                },
                success: function (dt) {
                    if (dt.total < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        $('#pagination').twbsPagination("destroy");
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染

                    var html = template('dataItemTpl', dt);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: dt.total,
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            search();
                        }
                    });
                }
            });
        }

        function edit(id) {
            var url = '@Url.Action("BlackDayEdit", "Sms")' + "?id=" + id;
            var taskid = @ViewBag.TaskId;
            var tl = '短信任务执行周期管理';
            BMCW.showTopLayer(tl, url, 630, 298);
        }

        function del(id) {
            var url = '@Url.Action("DelBlackDay", "Sms")'
            BMCW.DataConfirm("", function () {
                BMCW.ajax({
                    url: url,
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function (o) {
                        if (o.status == 0) {
                            BMCW.msg("删除成功", function () {
                                search();
                            });

                        } else {
                            BMCW.alert(o.message);
                        }
                    }
                });
            })
        }
    </script>
}









